package br.com.rhinovet.logica.impl;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Map;

import org.springframework.stereotype.Service;

@Service("emailCirurgiaLogica")
public class LeitorEmailCirurgiaLogica  {

	public String popularSubCategoriaCirurgia(Map<String, String> mapPropriedades) throws Exception {
		InputStream input = null;
		StringBuilder sb = new StringBuilder();
		try {
			input = getClass().getResourceAsStream("/email/consulta.xhtml");
			if (input == null) {
				System.out.println("Não foi possível obter o template de dados para o email");
			}
			InputStreamReader is = new InputStreamReader(input);
			
			BufferedReader br = new BufferedReader(is);
			String read = br.readLine();
			
			while(read != null) {
				System.out.println(read);
			    sb.append(read);
			    read = br.readLine();
			}
			
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			if (input != null) {
				try {
					input.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		
		return sb.toString();
		
	}

}